<template>
  <div class="dashboard-container">
    <el-row :gutter="20">
      <el-col :span="8">
        <el-card shadow="hover" class="mgb20" style="height: 500px">
          <div class="user-info">
            <div class="user-info-cont">
              <div class="user-info-name" style="margin-bottom: 6px;color: #aa55ff;">{{username}}</div>
              <div>{{mailbox}}</div>
            </div>
          </div>
          <dev style="font-size: 16px;color: cornflowerblue;margin-right: 15px;">
            绑定HWID:
            <el-tag type="success" effect="plain" style="margin-left: 10px;">
              {{ hwid }}
            </el-tag>
          </dev>
          <el-button type="danger" plain style="width: 100px;font-size: 10px;left: 5px;margin-bottom: 25px;">重置HWID
          </el-button>
          <br>
          <dev style="font-size: 16px;color: brown">
            用户套餐:
            <el-tag type="warning" effect="plain" style="margin-left: 20px;">
              {{ usersetMeal }}
            </el-tag>
          </dev>
          <br>
          <el-button type="primary" plain style="margin-left: 0px;margin-top: 20px;">{{downloadUrl}}</el-button>
          <el-button type="info" plain>重置加载器</el-button>
        </el-card>
      </el-col>
      <el-col :span="16">
        <el-row :gutter="20" class="mgb20">
          <el-col :span="8">
            <el-card shadow="hover" :body-style="{padding: '0px'}">
              <div class="grid-content grid-con-1">
                <i class="el-icon-user grid-con-icon"></i>
                <div class="grid-cont-right">
                  <div class="grid-num">{{SystemInfo.userAmount}}</div>
                  <div style="padding-top: 10px;font-size: 17px;">AegisCloud人数</div>
                </div>
              </div>
            </el-card>
          </el-col>
          <el-col :span="8">
            <el-card shadow="hover" :body-style="{padding: '0px'}">
              <div class="grid-content grid-con-2">
                <i class="el-icon-s-shop grid-con-icon"></i>
                <div class="grid-cont-right">
                  <div class="grid-num">{{SystemInfo.luaAmount}}</div>
                  <div style="padding-top: 10px;font-size: 17px;">云市场Lua数量</div>
                </div>
              </div>
            </el-card>
          </el-col>
          <el-col :span="8">
            <el-card shadow="hover" :body-style="{padding: '0px'}">
              <div class="grid-content grid-con-3">
                <i class="el-icon-ice-cream-round grid-con-icon"></i>
                <div class="grid-cont-right">
                  <div class="grid-num">{{SystemInfo.loadAmount}}</div>
                  <div style="padding-top: 10px;font-size: 17px;">全球访问次数</div>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
        <el-card shadow="hover" style="height:403px;">
          <div slot="header" class="clearfix">
            <span>公告</span>
          </div>
          <el-table :show-header="false" :data="todoList" style="width:100%;">
            <el-table-column width="40">
              <template slot-scope="scope">
                <el-checkbox v-model="scope.row.status"></el-checkbox>
              </template>
            </el-table-column>
            <el-table-column>
              <template slot-scope="scope">
                <div class="todo-item" :class="{'todo-item-del': scope.row.status}">{{scope.row.title}}
                </div>
              </template>
            </el-table-column>
            <el-table-column width="60">
              <template>
                <i class="el-icon-edit"></i>
                <i class="el-icon-delete"></i>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>

    <div class="tips">
      <span style="margin-right:20px;margin-top: 10px;">Developed by XiaoZhengRS | © AegisCloud Lua inc.</span>
    </div>
  </div>
</template>

<script>
import {
  mapGetters
} from 'vuex'

import {
  api_getInfo
} from "@/api/system"

export default {
  name: 'Dashboard',
  data() {
    return {
      username: "正在加载..",
      mailbox: "正在加载..",
      hwid: "正在加载..",
      usersetMeal: "正在加载..",
      downloadUrl: "下载加载器 (正在加载..)",
      todoList: [{
        title: '欢迎使用AegisCloud系统',
        content: "10",
        publishTime: "2022年6月9日"
      },
        {
          title: '用户条款请务必查看',
          content: "10",
          publishTime: "2022年6月9日"
        }
      ],
      Timer: {
        SystemInfo: null
      },
      SystemInfo: {
        userAmount: 0,
        luaAmount: 0,
        loadAmount: 0

      }
    }
  },
  methods: {
    async initData() {
      const res = await api_getInfo()
      if (res === null) return;
      this.SystemInfo.userAmount = res.data.userAmount
      this.SystemInfo.luaAmount = res.data.luaAmount
      this.SystemInfo.loadAmount = res.data.loadAmount
      this.username = res.data.username
      this.mailbox = res.data.mailbox
      this.hwid = res.data.hwid
      this.usersetMeal = res.data.subTab
      this.downloadUrl = res.data.downloadUrl
      console.log(res);
    }
  },
  created() {
    this.initData()
  }
}
</script>

<style lang="scss" scoped>
.tips {
  font-size: 16px;
  color: #aa55ff;
  margin-bottom: 18px;

  span {
    &:first-of-type {
      margin-right: 16px;
    }
  }
}

.dashboard {
  &-container {
    margin: 30px;
  }

  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}

.el-row {
  margin-bottom: 20px;
}

.grid-content {
  display: flex;
  align-items: center;
  height: 100px;
}

.grid-cont-right {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: #999;
}

.grid-num {
  font-size: 30px;
  font-weight: bold;
}

.grid-con-icon {
  font-size: 50px;
  width: 100px;
  height: 100px;
  text-align: center;
  line-height: 100px;
  color: #fff;
}

.grid-con-1 .grid-con-icon {
  background: rgb(45, 140, 240);
}

.grid-con-1 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-2 .grid-con-icon {
  background: rgb(100, 213, 114);
}

.grid-con-2 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-3 .grid-con-icon {
  background: rgb(242, 94, 67);
}

.grid-con-3 .grid-num {
  color: rgb(242, 94, 67);
}

.user-info {
  display: flex;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 2px solid #ccc;
  margin-bottom: 20px;
}

.user-avator {
  width: 120px;
  height: 120px;
  border-radius: 50%;
}

.user-info-cont {
  padding-left: 50px;
  flex: 1;
  font-size: 14px;
  color: #999;
}

.user-info-cont div:first-child {
  font-size: 30px;
  color: #222;
}

.user-info-list {
  font-size: 14px;
  color: #999;
  line-height: 25px;
}

.user-info-list span {
  margin-left: 70px;
}

.mgb20 {
  margin-bottom: 20px;
}

.todo-item {
  font-size: 14px;
}

.todo-item-del {
  text-decoration: line-through;
  color: #999;
}

.schart {
  width: 100%;
  height: 300px;
}
</style>
